package com.cn.mmd.controller;

import com.cn.mmd.model.Grade;
import com.cn.mmd.model.StudentApp;
import com.cn.mmd.service.GradeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/7/21 0021.
 */
@Controller
@RequestMapping(value = "page/studentGrade")
public class StudentGradeController {

    @Autowired
    private GradeService gradeService;

    @Autowired
    private TokenController tokenController;

//    @RequiresPermissions("user:create")
    @RequestMapping(value = "/select")
    @ResponseBody public synchronized Object stuSelectGrade(HttpServletRequest request){
        Map<String,Object> objectMap = new HashMap<String, Object>();
//        List<Map> mapList = new ArrayList<Map>();
//        Map<String,Object> map;
//        String studentId = request.getParameter("studentId");
//        String token = request.getParameter("token");
//        StudentApp studentApp;
//        studentApp = (StudentApp) tokenController.token1(studentId, token);
//        if (studentApp != null) {
//            Grade grade = new Grade();
//            grade.setStuid(studentId);
//            List<Grade> gradeList = gradeService.selectByStuId(grade);
//            if (gradeList != null) {
//                if (gradeList.size() > 0) {
//                    for (int i = 0; i < gradeList.size(); i++) {
//                        map = new HashMap<String, Object>();
//                        grade = gradeList.get(i);
//                        if (grade != null) {
//                            map.put("gradeId", grade.getGradeid() + "");
//                            map.put("teacherId", grade.getTeacherid());
//                            map.put("courseId", grade.getCoursespuid());
//                            map.put("totalGrade", grade.getTotalgrade() + "");
//                            mapList.add(map);
//                        }
//                    }
//                    if (mapList != null && mapList.size() == gradeList.size()) {
//                        objectMap.put("data", mapList);
//                        objectMap.put("code", 200);
//                        objectMap.put("message", "成功");
//                    } else {
//                        objectMap.put("code", 201);
//                        objectMap.put("message", "查看失败");
//                    }
//                } else {
//                    objectMap.put("code", 202);
//                    objectMap.put("message", "暂无成绩");
//                }
//            }
//        }else {
//            objectMap.put("code", 203);
//            objectMap.put("message", "此用户没有权限做此操作");
//        }
        return objectMap;
    }
}
